PostgreSQL Sakila示例库

1 背景知识

Sakila示例库PostgreSQL 数据库原生的示例数据,目前有 Sakila示例库。这里是此示例库的官方网站

2 Sakila E-R模型

2.1 Sakila E-R模型图

sakila E-R 模型图|500

2.2 sakilaE-R E-R 图说明

3 Sakila 实例库的使用

3.1 上传脚本文件

  1. 上传postgres-sakila-db文件夹 到/soft
  2. 更改脚本属主和属主
su - root
chown postgres:postgres /soft/  -R

3.2 导入数据

psql -U postgres -d postgres
createdb testdb
psql -U postgres -d testdb -f /soft/postgres-sakila-db/postgres-sakila-schema.sql 
psql -U postgres -d testdb -f /soft/postgres-sakila-db/postgres-sakila-insert-data.sql

3.3 删除数据

psql -U postgres -d testdb -f /soft/postgres-sakila-db/postgres-sakila-drop-objects.sql

3.4 学习网站

PostgreSQL SELECT 语句 (sjkjc.com) 这个网站是使用了 sakila 实例库用到的 SQL语句的示例。

4 更多的示例库

如果需要更多的示例库,请参考示例数据库 - PostgreSQL wiki